package client.screen;

import javax.microedition.lcdui.*;

import client.functionalities.LocalFunctionality;
import client.functionalities.RemoteFunctionality;
import client.util.AlertThread;

public class AlertScreen extends Alert implements CommandListener {
	private Command back; 
	private AlertThread alertThread;
	
	public AlertScreen(String title) {
		super(title);
		
		this.back = new Command("Voltar", Command.BACK, 0);
		
		this.setCommandListener(this);
	}
	
	public void newAlertThread(LocalFunctionality lf, String message) {
		alertThread = new AlertThread(this, lf, message);
	}
	
	public void newAlertThread(RemoteFunctionality f, String message) {
		alertThread = new AlertThread(this, f, message);
	}

	public void startThread() { alertThread.start(); }
	
	public void commandAction(Command c, Displayable d) {
		if (c == back) {
			alertThread.interrupt();
		}
	}
	
}
